﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data.OleDb;
using System.Windows.Forms;
//
using System.Configuration;
using System.IO;
namespace DLLTest.OpertionClass
{
    class DataCon
    {
        /*本系统采用Access2003数据库，必须引用using System.Data.OleDB
         * 定义了getCon()方法，连接数据库 
         * 主要是数据连接类
         */
        ///<summary>
        ///获得连接字符串
        ///</summary>
       // public static string connStr =  ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;//从配置文件中读取数据连接字符串 
        //public static string connStr = System.Windows.Forms.Application.StartupPath + @".\DataBase\db_VWMS.mdb";
       // public static string connStr = Application.StartupPath +@"\DataBase\db_VWMS.mdb";

        public OleDbConnection getCon()
        {
            //string strDPath = Application.StartupPath;
            string strDPath = Application.StartupPath + "\\DataBase\\db_VWMS.mdb";
            string strDataSource = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + strDPath.Substring(0, strDPath.LastIndexOf("\\")).Substring(0, strDPath.Substring(0, strDPath.LastIndexOf("\\")).LastIndexOf("\\")) + "\\DataBase\\db_VWMS.mdb;Jet OLEDB:Database Password=Fanxuanxuan123";
            //string strDataSource = connStr;       
            OleDbConnection oledbCon = new OleDbConnection(strDataSource);
            return oledbCon;
        }
    }
}
